#include using namespace std; //STRING PARSING - breaking apart a string into logical chuncks //Tokens - the parts of the string that are delimited //Delimiter - is the char or characters used as markers to seperate a string into // its parts void main() { char phrase[1000]; cin.getline(phrase,1000); //strtok - replaces all of the delimiters with '\0's and returns the //address of the first token, //when you call it again it returns the addess of the next token //keep calling it until NULL is returned char* token = strtok(phrase," \t\n\r"); while(token != NULL) { if(strlen(token) > 0) cout << token << endl; token = strtok(NULL," \t\n\r"); } //the origional phrase is now trashed cout << phrase; } //void main() //{ // char phrase[1000]; // cin.getline(phrase,1000); // // char word[100]; // int wordIndex = 0; // // //this is a test // // //returns the address of where a char is found in a string // //this function returns NULL if the char is not found // //NULL is the address 0 // char* start = phrase; // char* p = strchr(start,' '); // //if p is not NULL we found a space // while(p != NULL) // { // int indexOfSpace = int(p - start); // strncpy(word,start, indexOfSpace); // word[indexOfSpace] = '\0'; // cout << word << endl; // // start = p + 1; // p = strchr(start, ' '); // } // // cout << start << endl; // // //}